﻿@{
    ViewBag.Title = "客户资料管理";
    Layout = "~/Views/Shared/_Form.cshtml";
}

<script>
    var keyValue = request('keyValue');
    var pstructId = request('pstructId');
    var type = request('type');
    var LinkManId = "", FamilyMemberId = "", _OrganizeId = "";
    $(function () {
        initControl();
    })
    //初始化控件
    function initControl() {
        //住户类别选择
        $("#Flag").ComboBox({
            data: [{ key: 1, value: "个人" }, { key: 2, value: "企业" }],
            id: "key",
            text: "value",
            description: "==请选择==",
            click: function (item) {
                var flag = item.attr('data-value');
                if (flag == 2) {
                    $(".Enterprise").removeAttr("hidden");
                    $(".Personal").attr("hidden", "hidden");

                }
                else if (flag == 1) {
                    $(".Enterprise").attr("hidden", "hidden");
                    $(".Personal").removeAttr("hidden");
                }
            }
        });
        $("#Flag").ComboBoxSetValue(2);
        $(".Personal").attr("hidden", "hidden");

        //住户类型选择
        $("#Type").ComboBox({
            data: [{ key: 1, value: "业主" }, { key: 2, value: "租户" }],
            id: "key",
            text: "value",
            description: "==请选择==",
            click: function (item) {
                var type = item.attr('data-value');

            }
        });
        $("#Type").ComboBoxSetValue(2);

        //所属房间
        $("#PStructTree").ComboBoxTree({
            url: "../../ResourceManage/RS_PStructs/GetTreeJson?type=5",
            description: "==请选择==",
            height: "250px",
            click: function (item) {
                type = item.Type;
                if (item.Type == "5") {
                    pstructId = item.id;
                    _OrganizeId = item.value;
                }
                else { dialogMsg('请选择房间', 0); }
            }
        });

        //证件类型选择
        $("#CertificateType").ComboBox({
            data: [{ key: 1, value: "身份证" }, { key: 2, value: "护照" }, { key: 3, value: "营业执照" }],
            id: "key",
            text: "value",
            description: "==请选择==",
        });


        //性别
        $("#Gender").ComboBox({
            data: [{ key: 1, value: "男" }, { key: 0, value: "女" }],
            id: "key",
            text: "value",
            description: "==请选择==",
        });
        $("#Gender").ComboBoxSetValue(1);

        ////加载自定义表单
        //var moduleId = top.$.cookie('currentmoduleId');
        //$.SetForm({
        //    url: "../../AuthorizeManage/ModuleForm/GetEntityJsonByModuleId",
        //    param: { "keyValue": moduleId, "objectId": keyValue },
        //    async: true,
        //    success: function (data) {
        //        $('#frmpreview').frmPreview({
        //            tablecotent: data.form.FormJson,
        //            width: 700
        //        });
        //        formId = data.form.FormId;
        //        if (data.instance != null) {
        //            $('#frmpreview').frmSetData(JSON.parse(data.instance.FormInstanceJson));
        //            instanceId = data.instance.FormInstanceId;
        //        }
        //    }
        //});

        //获取表单
        if (!!keyValue) {
            $.SetForm({
                url: "../../ResourceManage/RS_PStructUser/GetFormJson",
                param: { keyValue: keyValue },
                success: function (data) {
                    
                    $("#form1").SetWebControls(data.data);
                    $("#form1").SetWebControls(data.model);
                    $("#Type").ComboBoxSetValue(data.data.Type);
                    $("#Flag").ComboBoxSetValue(data.data.Flag);
                    $("#CertificateType").ComboBoxSetValue(data.data.CertificateType);
                    $("#Gender").ComboBoxSetValue(data.data.Gender);
                    $("#PStructTree").ComboBoxTreeSetValue(data.PStructId);
                    type = "5";
                    if (data.data.Flag == 2) {
                        $(".Enterprise").removeAttr("hidden");
                        $(".Personal").attr("hidden", "hidden");
                    }
                    else if (data.data.Flag == 1) {
                        $(".Enterprise").attr("hidden", "hidden");
                        $(".Personal").removeAttr("hidden");
                    }
                }
            });
        }

    }

    //保存表单
    function AcceptClick() {
        if (type != "5") {
            dialogMsg('请选择房间', 0); return false;
        }
        if (!$('#form1').Validform()) {
            return false;
        }
       
        var postData = $("#form1").GetWebControls(keyValue);
        postData["PStructId"] = pstructId;
        postData["OrganizeId"] = _OrganizeId;
        $.SaveForm({
            url: "../../ResourceManage/RS_PStructUser/SaveForm?keyValue=" + keyValue,
            param: postData,
            loading: "正在保存数据...",
            success: function () {
                $.currentIframe().$("#gridTable").resetSelection();
                $.currentIframe().$("#gridTable").trigger("reloadGrid");
            }
        })


    }
</script>



<div style="margin-left: 10px; margin-top: 20px; margin-right: 30px;">
    <ul class="nav nav-tabs">
        <li class="active"><a href="#BaseInfo" data-toggle="tab">基本信息</a></li>
        <li><a href="#ExpandInfo" data-toggle="tab">扩展信息</a></li>
    </ul>
    <div class="tab-content" style="padding-top: 15px;">
        <div id="BaseInfo" class="tab-pane active">
            <table class="form">
                <tr>
                    <th class="formTitle">客户类别<font face="宋体">*</font></th>
                    <td class="formValue">
                        <div id="Flag" type="selectTree" class="ui-select" isvalid="yes" checkexpession="NotNull">    </div>
                    </td>
                    <th class="formTitle">客户类型<font face="宋体">*</font></th>
                    <td class="formValue">
                        <div id="Type" type="selectTree" class="ui-select" isvalid="yes" checkexpession="NotNull">  </div>
                    </td>
                </tr>
                <tr>
                    <th class="formTitle">名称<font face="宋体">*</font></th>
                    <td class="formValue">
                        <input id="Name" type="text" class="form-control" isvalid="yes" checkexpession="NotNull" />
                    </td>
                    <th class="formTitle">编码<font face="宋体">*</font></th>
                    <td class="formValue">
                        <input id="Code" type="text" class="form-control" isvalid="yes" checkexpession="NotNull" />
                    </td>

                </tr>
                <tr>
                    <th class="formTitle">所属房间<font face="宋体">*</font></th>
                    <td class="formValue">
                        <div id="PStructTree"  type="selectTree" class="ui-select" isvalid="yes" checkexpession="NotNull"></div>
                    </td>
                    <th class="formTitle">简称</th>
                    <td class="formValue">
                        <input id="ShortName" type="text" class="form-control" />
                    </td>
                </tr>
                <tr>
                    <th class="formTitle">入住时间</th>
                    <td class="formValue">
                        <input id="BeginDate" type="text" class="form-control input-wdatepicker" onfocus="WdatePicker({maxDate:'#F{$dp.$D(\'EndDate\')}'})" />
                    </td>
                    <th class="formTitle">离开时间</th>
                    <td class="formValue">
                        <input id="EndDate" type="text" class="form-control input-wdatepicker" onfocus="WdatePicker({ minDate: '#F{$dp.$D(\'BeginDate\')}' })" />
                    </td>
                </tr>
                <tr class="Enterprise">
                    <th class="formTitle">企业性质</th>
                    <td class="formValue">
                        <input id="Nature" type="text" class="form-control" />
                    </td>
                    <th class="formTitle">注册资本</th>
                    <td class="formValue">
                        <input id="Capital" type="text" class="form-control" />
                    </td>
                </tr>
                <tr class="Enterprise">
                    <th class="formTitle">营业执照号</th>
                    <td class="formValue">
                        <input id="Licene" type="text" class="form-control" />
                    </td>
                    <th class="formTitle">法人名称</th>
                    <td class="formValue">
                        <input id="Legal" type="text" class="form-control" />
                    </td>
                </tr>
                <tr>
                    <th class="formTitle">证件类型</th>
                    <td class="formValue">
                        <div id="CertificateType" type="selectTree" class="ui-select">  </div>
                    </td>
                    <th class="formTitle">证件编号</th>
                    <td class="formValue">
                        <input id="CertificateNO" type="text" class="form-control" />
                    </td>
                </tr>
                <tr>
                    <th class="formTitle">手机号码<font face="宋体">*</font></th>
                    <td class="formValue">
                        <input id="PhoneNum" type="number" class="form-control" isvalid="yes" checkexpession="NotNull" />
                    </td>
                    <th class="formTitle">电话号码</th>
                    <td class="formValue">
                        <input id="TelPhoneNum" type="number" class="form-control" />
                    </td>
                </tr>
                <tr>
                    <th class="formTitle">紧急联系人</th>
                    <td class="formValue">
                        <input id="LinkMan" type="text" class="form-control" />
                    </td>
                    <th class="formTitle">紧急联系人电话</th>
                    <td class="formValue">
                        <input id="LinkPhoneNum" type="number" class="form-control" />
                    </td>
                </tr>
                <tr>
                    <th class="formTitle">联系地址</th>
                    <td class="formValue">
                        <input id="Address" type="text" class="form-control" />
                    </td>
                    <th class="formTitle">传真号码</th>
                    <td class="formValue">
                        <input id="Fax" type="text" class="form-control" />
                    </td>
                </tr>
                <tr class="Personal">
                    <th class="formTitle">性别</th>
                    <td class="formValue">
                        <div id="Gender" type="selectTree" class="ui-select">

                        </div>
                    </td>
                    <th class="formTitle">出生年月</th>
                    <td class="formValue">
                        <input id="Date" type="text" class="form-control input-wdatepicker" onfocus="WdatePicker({})" />
                    </td>
                </tr>
                <tr class="Personal">
                    <th class="formTitle">国籍</th>
                    <td class="formValue">
                        <input id="Nation" type="text" class="form-control" />
                    </td>
                    <th class="formTitle">邮箱</th>
                    <td class="formValue">
                        <input id="Email" type="text" class="form-control" />
                    </td>

                </tr>

                <tr class="Personal">
                    <th class="formTitle">WebChat</th>
                    <td class="formValue">
                        <input id="WeChat" type="number" class="form-control" />
                    </td>
                    <th class="formTitle">QQ</th>
                    <td class="formValue">
                        <input id="QQ" type="number" class="form-control" />
                    </td>
                </tr>
                <tr>
                    <th class="formTitle">
                        备注
                    </th>
                    <td class="formValue" colspan="3">
                        <textarea id="Memo" class="form-control" style="height: 70px;"></textarea>
                    </td>
                </tr>
            </table>
        </div>
        <div id="ExpandInfo" class="tab-pane ">
            <div class="app_layout app_preview" id="frmpreview" style=" padding-right: 30px;">
            </div>
        </div>
    </div>
</div>
